package com.myhome.controller;

import com.myhome.entity.Admin;
import com.myhome.entity.RespBean;
import com.myhome.service.IAdminService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class AdminInfoController {
    @Autowired
    IAdminService adminService;

    @ApiOperation(value = "修改基本信息")
    @PostMapping("/admin/basicInfo")
    public RespBean updateAdminBasicInfo(Admin admin) {
        if (adminService.updateById(admin)) {
            return RespBean.success("修改成功");
        }
        return RespBean.error("修改失败");
    }

    @ApiOperation(value = "修改密码")
    @PostMapping("/admin/pass")
    public RespBean updateAdminPassword(@RequestBody Map<String,Object> password, Authentication authentication){
        return adminService.updateAdminPassword(password,authentication);
    }
}
